473,468 Members | 3,847 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Displaying drop-down list boxes for every row in a DataGrid \ Repe

Hi,

Even tough I was able to implement what I want in a weird and non efficient
way, I would like to get an opinion what is the right way to achieve my task:

Scenario:
• Display a DataGrid that contains rows from a table from a databse (so far
easy).
• I would like to add a column to the DataGrid that will be a drop-down list
so the user will be able to select a value from a pre-defined list of values
for every row in the DataGrid. (every row should have a drop-down)
• When the user will post back the form I would like to refer to every value
in the drop-down list by name.
• In order to implement this I used a TemplateColumn in the DataGrid, but I
had a hard time giving a name to the <select> element so I will be able to
refer to it when the form will be posted back. I have used a weird syntax
(with data binding syntax since the container is not the DataGrid but a
DataGrid item) to create a unique name for each one of the <select> elements.
This caused the Design-View in Visual Studio to not be able to display the
page even though it did work at run time.
Somehow I feel that I took the wrong way to display a drop-down for each and
every row in the data grid.

Any opinions?

--
Thanks
Eric
Nov 19 '05 #1
2 2381
i thing simpliest way is to use DropDownList instead of select control
your code may be like this:

<asp:datagrid id="mygrid"
....
<ItemTemplate>
<asp:DropDownList id="MyList" runat="server" />
<ItemTemplate>...

and in your postback handler you can use:
foreach (DataGridItem item in mygrid.Items)
{
if (item.ItemType = ListItemType.Item || item.ItemType =
ListItemType.AlternatingItem)
{
DropDownList list = item.FindControl("MyList") as DropDownList;
...
}
}

"Eric Dan" <no****@stopspamming.com> wrote in message
news:AC**********************************@microsof t.com...
Hi,

Even tough I was able to implement what I want in a weird and non efficient way, I would like to get an opinion what is the right way to achieve my task:
Scenario:
. Display a DataGrid that contains rows from a table from a databse (so far easy).
. I would like to add a column to the DataGrid that will be a drop-down list so the user will be able to select a value from a pre-defined list of values for every row in the DataGrid. (every row should have a drop-down)
. When the user will post back the form I would like to refer to every value in the drop-down list by name.
. In order to implement this I used a TemplateColumn in the DataGrid, but I had a hard time giving a name to the <select> element so I will be able to
refer to it when the form will be posted back. I have used a weird syntax
(with data binding syntax since the container is not the DataGrid but a
DataGrid item) to create a unique name for each one of the <select> elements. This caused the Design-View in Visual Studio to not be able to display the
page even though it did work at run time.
Somehow I feel that I took the wrong way to display a drop-down for each and every row in the data grid.

Any opinions?

--
Thanks
Eric

Nov 19 '05 #2
Thanks a lot

It is definitely the best solution

Eric

"Jakub" wrote:
i thing simpliest way is to use DropDownList instead of select control
your code may be like this:

<asp:datagrid id="mygrid"
....
<ItemTemplate>
<asp:DropDownList id="MyList" runat="server" />
<ItemTemplate>...

and in your postback handler you can use:
foreach (DataGridItem item in mygrid.Items)
{
if (item.ItemType = ListItemType.Item || item.ItemType =
ListItemType.AlternatingItem)
{
DropDownList list = item.FindControl("MyList") as DropDownList;
...
}
}

"Eric Dan" <no****@stopspamming.com> wrote in message
news:AC**********************************@microsof t.com...
Hi,

Even tough I was able to implement what I want in a weird and non

efficient
way, I would like to get an opinion what is the right way to achieve my

task:

Scenario:
. Display a DataGrid that contains rows from a table from a databse (so

far
easy).
. I would like to add a column to the DataGrid that will be a drop-down

list
so the user will be able to select a value from a pre-defined list of

values
for every row in the DataGrid. (every row should have a drop-down)
. When the user will post back the form I would like to refer to every

value
in the drop-down list by name.
. In order to implement this I used a TemplateColumn in the DataGrid, but

I
had a hard time giving a name to the <select> element so I will be able to
refer to it when the form will be posted back. I have used a weird syntax
(with data binding syntax since the container is not the DataGrid but a
DataGrid item) to create a unique name for each one of the <select>

elements.
This caused the Design-View in Visual Studio to not be able to display the
page even though it did work at run time.
Somehow I feel that I took the wrong way to display a drop-down for each

and
every row in the data grid.

Any opinions?

--
Thanks
Eric


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Xiao Tencas | last post by:
When trying to load a png image in GD, I get the error (Mozilla Firefox) "cannot display image, because it contains errors"; IE just shows an empty 'image-error' box. When loading a large enough...
1
by: srikanth | last post by:
Hi all, I have an requirement in one of my projects. We have one aspx page, in that we have two frames, in each frame having a tree structure control(dynamic data). In the left Frame we are...
1
by: Richard | last post by:
I have a framed page, with a 100 pixel deep header section. I've coded the JSCookMenu in that frame, but the drop downs get cut in half ..... ie. the drop downs only display within that frame and...
1
by: buzz | last post by:
I've created a simple table with text and images(gif, jpg) in a user control. Everything displays correctly in the designer. But when I drop the control on the main page, no images display. What am I...
0
by: ViRi | last post by:
I am currently experimenting a bit with AxMicrosoft.MediaPlayer.Intero­p.AxWindowsMediaPlayer and so far, most has gone well. Currently, i would like to add drag-and-drop functionality to the...
8
by: Jon Weston | last post by:
I'm setting up an Access2003 database with pictures. I put a bound ole picture ctrl on a form that's source is the table that contains the pictures and follow ALL the directions for embedding a...
9
by: piyush2884 | last post by:
hi guys, got anything on this issue?
3
by: cmc12 | last post by:
Hi, I'm raising an error from the dB to an Application like theis RAISE_APPLICATION_ERROR(-20000, 'Contact Support'); the thing is the error printed on screen contains the -20000, is there any...
10
by: gnewsgroup | last post by:
I've googled and tried various approaches, but could not resolve this problem. The article at MSDN: Displaying Images in a GridView Column only presents a simple case where all data (including the...
0
by: nataraj jaideep | last post by:
Hi, I want to apply drop shadow for my tooltip. If i give the below script--> filter: progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#000000'); to my css, the drop shadow...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.